const { query } = require('../config/db.config');

class goods {
  static async findAll() {
    return await query('SELECT * FROM goods_table');
  }

  static async findById(id) {
    const [goods] = await query('SELECT * FROM goods_table WHERE id = ?', [id]);
    return goods;
  }

  static async create(id, name, adress,descript, price, number) {
    const result = await query(
      'INSERT INTO goods_table (id, name, adress,descript, price, number) VALUES (?, ?, ?, ?, ?, ?)',
      [id, name, adress,descript, price, number]
    );
    console.log(result)
    return result; // 返回新创建的ID
  }
}

module.exports = goods;